package com.concerneyes.mine.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.concerneyes.R;

/**
 * Created by Administrator on 2017/6/21 0021.
 */

public class MeListAdapter extends BaseAdapter {
    private String[] listName;
    private int[] listIcon;
    private Context context;


    public MeListAdapter(Context context) {
        this.context = context;
        listName = context.getResources().getStringArray(R.array.mine_item_title);
        listIcon = new int[]{R.drawable.wode_wdqb, R.drawable.wode_wddd, R.drawable.wode_yhgl,
                R.drawable.wode_yhgl, R.drawable.wode_hdzx, R.drawable.wode_ffzx,
                R.drawable.wode_ffzx,R.drawable.wode_shezhi};
    }

    @Override
    public int getCount() {
        return listName.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
                ViewHolder holder = null;
                if (convertView == null) {

                    holder = new ViewHolder();
                    convertView = LayoutInflater.from(context).inflate(R.layout.item_list_me, null);
                    holder.ivIcon = (ImageView) convertView.findViewById(R.id.iv_me_icons);
                    holder.tvName = (TextView) convertView.findViewById(R.id.tv_me_title);
                    holder.rl_item = (RelativeLayout) convertView.findViewById(R.id.rl_item);
                    holder.view_diver = (View) convertView.findViewById(R.id.view_diver);
                    convertView.setTag(holder);
                } else {
                    holder = (ViewHolder) convertView.getTag();
                }
                switch (position) {
                    case 3:
                        holder.rl_item.setVisibility(View.GONE);
                        holder.view_diver.setVisibility(View.VISIBLE);
                        break;
                    case 6:
                        holder.rl_item.setVisibility(View.GONE);
                        holder.view_diver.setVisibility(View.VISIBLE);
                        break;
                    default:
                        holder.rl_item.setVisibility(View.VISIBLE);
                        holder.view_diver.setVisibility(View.GONE);
                        holder.ivIcon.setImageResource(listIcon[position]);
                        holder.tvName.setText(listName[position]);
                }
        return convertView;
    }

    class ViewHolder {
        ImageView ivIcon;
        TextView tvName;
        RelativeLayout rl_item;
        View view_diver;
    }
}
